#coding=utf-8
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
cap = DesiredCapabilities()
def visit(driver):
    driver.maximize_window()
    driver.get("http://www.baidu.com")
    import time
    time.sleep(5)
    driver.quit()
th = []
hosts = {
    #通过zalenium方式
    #'http://172.19.0.5:40002/wd/hub': 'firefox',
    # 'http://172.19.0.3:40000/wd/hub': 'chrome',
    #'http://172.19.0.4:40001/wd/hub': 'chrome',
    #'http://172.19.0.6:40003/wd/hub': 'chrome'
    #通过zselenium grid方式
    # 'http://192.168.1.129:5001/wd/hub': 'chrome'
    #通过Selenoid 方式
    'http://192.168.1.130:14444/wd/hub': 'chrome'
}
# dcp = DesiredCapabilities()
for host, browser in hosts.items():
    from selenium.webdriver import Remote
    driver = Remote(
        command_executor=host,
        desired_capabilities = {
            "platform": "ANY",
            # 实时查看
            'enableVNC': True,
            "browserName": browser,
            'enableVideo': True,
            'videoName': "videoName"




        }
    )
    import threading
    th.append(threading.Thread(target=visit, args=[driver]))

for t in th:
    t.start()